package com.geek.javase.ch02.test5;

import java.util.concurrent.TimeUnit;
/*
 *@author wangpeng
 *2025/10/10 22:05
 *@description TODO
 */
public class Test {

    public static void main(String[] args) throws InterruptedException {
        Hero hero = new Hero("戚继光" , 9 , 1000.0 , 100.0 , 50.0 , "人类");
        Monster monster = new Monster("倭寇" , 10 , 2500.0 , 150.0 , 150.0 , "兽类");

        Equipment e1 = new Equipment("苗刀" , 5 , "红色" , 75.0 , 15.0 , "刀具");
        Equipment e2 = new Equipment("斧钺" , 3 , "紫色" , 45.0 , 10.0 , "斧头");
        Equipment e3 = new Equipment("火铳" , 7 , "蓝色" , 100.0 , 0.0 , "枪");
        Equipment e4 = new Equipment("竹盾" , 5 , "银色" , 75.0 , 0.0 , "盾");

        //hero.addEquip(e1);
        //hero.addEquip(e2);
        hero.addEquip(e3);
        //hero.addEquip(e4);

        //hero.show();
        //monster.show();

        //双方使用回合制的形式进行攻击
        int count = 0;
        while (true){
            System.out.println("---------- 第" + (++count) +" 回合攻击 -----------");

            //英雄攻击怪兽
            hero.attack(monster);
            if(monster.isDead()){
                System.out.println("怪兽已死亡");
                break;
            }

            //线程沉睡
            TimeUnit.MILLISECONDS.sleep(700);

            //怪兽攻击英雄
            monster.attack(hero);
            if(hero.isDead()){
                System.out.println("英雄已死亡");
                break;
            }

            //线程沉睡
            TimeUnit.MILLISECONDS.sleep(700);
        }
    }

}
